import type { IFieldProps, IConfigProps } from '@/components/sofastui/AdvancedTable/interface'
import type { FormRule } from '@form-create/element-ui'

export const fields: IFieldProps[] = [
  {
    label: 'ID',
    prop: 'id',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '厂商名称',
    prop: 'name',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '邮箱服务的主机',
    prop: 'host',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '邮箱服务的端口号',
    prop: 'port',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '邮箱账号',
    prop: 'user',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '描述',
    prop: 'desc',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '创建时间',
    prop: 'createdAt',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
  },
  {
    label: '修改时间',
    prop: 'updatedAt',
    minWidth: 60,
    import: true,
    export: true,
    search: true,
  },
]

export const config: IConfigProps = {
  name: 'sysEmailFirmTable',
  rowKey: 'id',
  url: '/api/sys/email_firm',
  selection: true,
  add: true,
  delete: true,
  expand: true,
  showIndex: true,
  import: true,
  export: true,
  search: true,
  advancedSearch: true,
  refresh: true,
  settings: true,
}

export const formRules: FormRule = [
  {
    type: 'input',
    field: 'name',
    title: '厂商名称',
    $required: true,
    props: {
      placeholder: '请输入厂商名称',
    },
    _fc_id: 'id_Fu1lmc22xd9zaic',
    name: 'name',
    display: true,
    hidden: false,
    _fc_drag_tag: 'input',
    col: {
      span: 12,
    },
  },
  {
    type: 'input',
    field: 'host',
    title: '服务主机',
    $required: true,
    props: {
      placeholder: '请输入服务主机',
    },
    _fc_id: 'id_Fja7mc22xer3alc',
    name: 'host',
    display: true,
    hidden: false,
    _fc_drag_tag: 'input',
    col: {
      span: 12,
    },
  },
  {
    type: 'input',
    field: 'port',
    title: '服务端口',
    $required: true,
    props: {
      placeholder: '请输入服务端口',
    },
    _fc_id: 'id_Fja7mc21xer3xlc',
    name: 'port',
    display: true,
    hidden: false,
    _fc_drag_tag: 'input',
    col: {
      span: 12,
    },
  },
  {
    type: 'radio',
    field: 'secure',
    title: '是否启用 SSL/TLS',
    effect: {
      fetch: '',
    },
    $required: true,
    props: {
      type: 'default',
      input: false,
    },
    value: 1,
    options: [
      {
        label: '是',
        value: 1,
      },
      {
        label: '否',
        value: 0,
      },
    ],
    _fc_id: 'id_Ftlcmc4wyz4rb4c',
    name: 'secure',
    _fc_drag_tag: 'radio',
    col: {
      span: 12,
    },
    display: true,
    hidden: false,
  },
  {
    type: 'input',
    field: 'user',
    title: '邮箱账户',
    $required: true,
    props: {
      placeholder: '请输入邮箱账户',
    },
    _fc_id: 'id_Fsa1mc21xe23xaa',
    name: 'user',
    display: true,
    hidden: false,
    _fc_drag_tag: 'input',
    col: {
      span: 12,
    },
  },
  {
    type: 'input',
    field: 'pass',
    title: '邮箱密码',
    $required: true,
    props: {
      placeholder: '请输入邮箱密码',
    },
    _fc_id: 'id_Fsa1aa21xe23xaa',
    name: 'pass',
    display: true,
    hidden: false,
    _fc_drag_tag: 'input',
    col: {
      span: 12,
    },
  },
  {
    type: 'input',
    field: 'desc',
    title: '备注',
    $required: false,
    props: {
      type: 'textarea',
      placeholder: '请输入备注',
    },
    _fc_id: 'id_Fwn9mc22xutzaoc',
    name: 'desc',
    display: true,
    hidden: false,
    _fc_drag_tag: 'textarea',
    col: {
      span: 24,
    },
  },
]
